package com.test.demo.main.fragment;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.test.demo.R;
import com.test.demo.base.BaseBottomFragment;
import com.test.demo.bean.Comment;
import com.test.demo.bean.RepostBean;
import com.test.demo.main.adapter.CommentAdapter;

import java.util.ArrayList;

/** 评论framgent */
public class CommentFragment extends BaseBottomFragment {

    RecyclerView recycler_view;

    ArrayList datas = new ArrayList<RepostBean>();

    CommentAdapter mAdapter;

    @Override
    protected int getContentViewId() {
        return R.layout.fragment_comment;
    }

    @Override
    protected void findViews() {
        recycler_view = findViewByIds(R.id.recycler_view);
    }

    @Override
    public void initGetData() {
        datas.clear();


        datas.add(new Comment("热爱和平的Tea", "23分钟前", R.drawable.logo_head, "请大佬们进群聊聊，这里有很多水友求带带呗", true, R.drawable.comment_img));
        datas.add(new Comment("热爱和平的Tea", "23分钟前", 0, "请大佬们进群聊聊，这里有很多水友求带带呗", false, R.drawable.two_people));
        datas.add(new Comment("热爱和平的Tea", "23分钟前", 0, "山谷地图今日上线!@Liping特种兵们速速前往打卡参观完别有洞天的古洞渠，来到气势磅礴的瀑布，再泡一泡可洗倦意的温泉，观赏着十里花香的鲁冰花海，这里有很多水友求带带呗", false, R.drawable.coment));

        mAdapter = new CommentAdapter(datas);
        recycler_view.setLayoutManager(new LinearLayoutManager(getActivity()));
        recycler_view.setAdapter(mAdapter);

        mAdapter.setOnItemListener(() -> {
            if (onListener != null) {
                onListener.onItemClick();
            }
        });
    }

    @Override
    protected void init() {

    }

    @Override
    protected void widgetListener() {

    }

    OnItemListener onListener;

    public interface OnItemListener {
        void onItemClick();
    }

    public void setOnItemListener(OnItemListener onListener) {
        this.onListener = onListener;
    }


}
